import json
from group import Group
from settings import change_design_velocity


def main():
    try:
        configs = json.load(open('config.json', encoding='utf-8'))

        level = 1 if configs.get('公路级别') is None else int(configs['公路级别'])
        design_v = configs.get('设计速度')
        change_design_velocity(design_v, level=level)

        for group_config in configs.get('文件', []):
            group = Group(group_config, level=level)
            group.run()
    except Exception as e:
        raise e


if __name__ == '__main__':
    main()
